using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Try_MytestList : Shop, IRequiresSessionState
{
	protected DataList DataList1;
	protected Label LbPage;
	protected HtmlForm form1;
	protected string StrOrderBy = " order by CreateTime Desc ";
	protected int ProductID = 0;
	protected string StrWhere1 = "";
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Init(object sender, EventArgs e)
	{
		try
		{
			Template.BindTemplateToPage(this.Page, "SaleProduct");
		}
		catch (Exception ex)
		{
			base.WriteTemErrMsg(ex.Message.ToString());
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.BindTryProductList();
		}
	}
	public void BindTryProductList()
	{
		CurrPageLinks currPageLinks = new CurrPageLinks();
		int num = 1;
		if (base.Request.QueryString["pageindex"] != null)
		{
			if (base.Request.QueryString["pageindex"].ToString() != "")
			{
				try
				{
					num = int.Parse(base.Request.QueryString["pageindex"].ToString());
				}
				catch (Exception ex)
				{
					ex.WriteErrorLog(new string[]
					{
						"正常操作"
					});
					num = 1;
				}
			}
		}
		if (base.Request.QueryString["ClassID"] != null)
		{
			this.StrWhere1 = " and ClassID=" + int.Parse(base.Request.QueryString["ClassID"]) + " ";
		}
		if (base.Request.QueryString["title"] != null && base.Request.QueryString["title"] != "")
		{
			this.StrWhere1 = " and ProductName like '%" + base.Request.QueryString["title"] + "%'";
		}
		if (base.Request.QueryString["tag"] != null)
		{
			if (base.Request.QueryString["tag"].ToString() == "Hits")
			{
				this.StrOrderBy = " order by Hits Desc ";
			}
		}
		int num2 = (num - 1) * 16;
		DataTable dataTable = this.conn.GetDataTable(string.Concat(new object[]
		{
			"select top 16 * from HLShop_TryProduct where IsElite=0 and TryID not in(select top ",
			num2,
			" TryID from HLShop_TryProduct where TryID>0 ",
			this.StrWhere1,
			" ",
			this.StrOrderBy,
			") ",
			this.StrWhere1,
			" ",
			this.StrOrderBy
		}));
		int count = dataTable.Rows.Count;
		this.DataList1.DataSource = dataTable;
		this.DataList1.DataBind();
		this.LbPage.Text = currPageLinks.CurrPageLink(num, 16, count, "个商品", "/Try/ShowMytestProduct.aspx?pageindex");
	}
	public string CountDays(string Date1, string Date2)
	{
		return (Convert.ToDateTime(Date2) - Convert.ToDateTime(Date1)).Days.ToString();
	}
	public string CountPeopleNum(string ProductID)
	{
		return this.conn.ExecuteCount("select count(*) from HLShop_TryAppcation where ProductID=" + int.Parse(ProductID)).ToString();
	}
}
